This invention discloses a programming method and system that solves the problems existing in prior art techniques for analyzing and correcting memory leaks in large Java Virtual Machine (JVM) “heaps” in which data elements or objects are stored in a managed heap. The introduction of Java Virtual Machines (JVMs) incorporating memory space for storing computer program instructions and data to be processed by 64-bit central processing units (CPUs) makes it possible to significantly increase the number of addressable memory locations (or “memory space”) and to increase the amount of data (or “heap size”) capable of being processed using the JVM. For example, with a 64-bit CPU, it is possible to specify JVM heap sizes of over 4 Gigabytes (GB). Diagnosing an unanticipated accumulation of data objects in memory (or “memory leak”) occurring as a result of JVM operations when it is utilizing a large heap size is not always possible with existing memory analysis tools (such as “hprof”), since such tools typically rely on obtaining a representation of data heap status using the “JVMPI” interface (Java Virtual Machine Profiler Interface) operated during “runtime” execution of the JVM program. The problem with this approach is that the JVMPI interface often cannot allocate sufficient memory to build such a “heap dump” representation when the heap size is large, and the JVM then ceases to function due to lack of remaining free memory and any possibility of analyzing the data heap to correct memory leaks that have occurred as a result of operation of the program is then lost.
Such an analysis is further complicated in cases where a memory leak occurs during actual operation of a “production” data processing system, due to the need to maintain an acceptable level of performance while the diagnosis proceeds during execution of the program, since most memory leak analysis tools cause a degradation in performance of the JVM application during operation and are therefore unsuited to correcting (or “debugging”) memory leaks in a “live” system. Standard “profiler” programs used to detect memory leaks are normally loaded into memory for execution only once during initialization of the JVM program and then remain in memory until operation of the JVM is terminated. However, due to the iterative nature of problem solving, incremental changes in the understanding of the problem will usually require such a profiler to be re-designed and re-coded in several cycles in order to extract the information needed to detect a memory leak, in turn causing multiple undesired “shutdown” and “restart” cycles during operation of the JVM program.
The invention discloses use of the “profiler” as a separate program tool to analyze “heap dumps” for identifying data elements or objects that may have experienced a memory leak, which allows the profiler to be modified and reloaded into memory for execution as necessary without ceasing operation of the JVM program. As a result, the runtime impact on the executed JVM application program is minimal, allowing memory leak analysis to be performed on a “live” system with a minimal degradation in performance.